﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserList.aspx.cs" MasterPageFile="~/Layouts/List.Master" Inherits="Bingosoft.WebApp.Modules.SecurityConsole.User.UserList" %>
<%@ Import Namespace="Bingosoft.Modules.SecurityConsole.Common.Helper" %>

<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">
    <!-- title -->
    <script type="text/javascript">
        var Global = {};
        Global.contextPath = '<%= RequestHelper.GetContextPath(Request) %>';
</script>
</asp:Content>

<asp:Content ID="idContent" ContentPlaceHolderID="Content" runat="Server">   
    <!-- 搜索框 -->
	<div class="search" style="margin-top:2px;">
     <web:search ID="GridSearch" GridViewId="SmartGridView1" runat="server">            
            <SearchConditionTemplate>                                       
                <img src="../../../Images/ico_have2.gif" class="pic" id="img_1" border="0" onclick="changeV('1')" />
        <table cellpadding="0" cellspacing="0" width="95%">
			<tr>
                <th>
                    用户名称：
                </th>
	            <td>
		            <asp:TextBox ID="Name" name="Name" runat="server"></asp:TextBox>
	            </td>
                <th>
                    用户账号：
                </th>
	            <td>
		            <asp:TextBox ID="LoginId" name="LoginId" runat="server"></asp:TextBox>
                   
	            </td>
                 <th>
                    账号状态：
                </th>
	            <td>
		             <asp:DropDownList ID="Status" runat="server">
                     <asp:ListItem Text="" Value=""></asp:ListItem>
                     <asp:ListItem Text="已启动" Value="enabled"></asp:ListItem>
                     <asp:ListItem Text="已停用" Value="disabled"></asp:ListItem>
                    </asp:DropDownList>
	            </td>
            </tr>
            <tbody id="tbody_1" style="border: 0px;">
						<tr>
						<td style="text-align: right">
							手机号码：
						</td>
						<td>
							<asp:TextBox ID="Mobile" name="Mobile" runat="server"></asp:TextBox>
						</td>
						<td>
							&nbsp;
						</td>
						<td>
							&nbsp;
						</td>
						<td>
							&nbsp;
						</td>
						<td>
							&nbsp;
						</td>
						<td>
							&nbsp;
						</td>
						<td>
							&nbsp;
						</td>
					</tr>
					</tbody>
			            
        </table>
            </SearchConditionTemplate>                      
        </web:search>
   
    </div>

    <div class="datalist">
	    <!-- 标题头 -->
	    <h2 style="height:30px;">
				    用户信息列表
	    </h2>
	    <!-- 工具栏 -->
	    <div class="toolbar" style="height:30px;">
            <asp:LinkButton ID="addUserButton" runat="server"
                OnClientClick="return openEditor(this, 'Insert');" OnClick="SearchGrid">
                <span>
                    <img alt="" runat="server" id="img1" src="~/Images/icon_new.gif" style="border: 0px" />新建
                </span>
            </asp:LinkButton>
             <asp:LinkButton ID="DeleteUsersButton" runat="server" _visible="USER_MANAGE$DELETE_USER"
                OnClientClick="return delFunctions();" OnClick="DeleteUsers">
                <span>
                    <img id="Img2" alt="" runat="server" src="~/Images/ico_del.gif" style="border: 0px" />删除
                </span>
            </asp:LinkButton>
	    </div>
	    <div class="datagrid"  style="clear:left;">    
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="USER_ID" DataSourceID="SmartDataSource1" 
                PageSize="10" onrowdatabound="SmartGridView1_RowDataBound">
                <Columns>            
                    <asp:CheckBoxField DataField="USER_ID" ItemStyle-HorizontalAlign="Center" />    
                    <asp:BoundField DataField="USER_NAME" HeaderText="用户名称" SortExpression="USER_NAME" ItemStyle-HorizontalAlign="Left"/>
                    <asp:BoundField DataField="ACCOUNT" HeaderText="用户账号" SortExpression="ACCOUNT" ItemStyle-HorizontalAlign="Left"/>
                    <asp:BoundField DataField="ORG_NAME" HeaderText="所在组织" SortExpression="ORG_NAME" ItemStyle-HorizontalAlign="Left" Visible="false" />
                  <%--  <web:DataDictonaryBoundField DictionaryCode="UserType" DataField="LOGIN_TYPE" HeaderText="帐号类型" SortExpression="LOGIN_TYPE" ItemStyle-HorizontalAlign="Center" />--%>
                    <asp:BoundField DataField="MOBILE" HeaderText="手机号码" SortExpression="MOBILE" ItemStyle-HorizontalAlign="Left" />
                    <web:DataDictonaryBoundField DictionaryCode="Sex" DataField="SEX" HeaderText="用户性别" SortExpression="SEX" ItemStyle-HorizontalAlign="center" />
                    <asp:BoundField DataField="STATUS" HeaderText="状态" SortExpression="STATUS" ItemStyle-HorizontalAlign="Center" />
            
                    <asp:TemplateField HeaderText="操作">
                
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnEdit" runat="server" ToolTip="编辑"  _KeyId='<%#Eval("USER_ID")%>'
                                            ImageUrl="~/Images/com/dg_edit.gif" CausesValidation="False" OnClientClick="return openEditor(this, 'Edit');" OnClick="RefreshGrid" _visible="USER_MANAGE$EDIT_USER">
                                        </asp:ImageButton>
                                    </td>

                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ImageButton1" runat="server" ToolTip="分配管理角色" ImageUrl="~/Images/ico_assign_role.gif" _KeyId='<%#Eval("USER_ID")%>'
                                            CausesValidation="False" OnClientClick="return showUserRoleList(this)" _visible="USER_MANAGE$ASSIGN_ROLE">
                                        </asp:ImageButton>
                                    </td>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ImageButton3" runat="server" ToolTip="分配流程角色" ImageUrl="~/Images/ico_entrust.gif"
                                            _KeyId='<%#Eval("USER_ID")%>' CausesValidation="False" OnClientClick="return showUserWfRoleList(this)"
                                            _visible="USER_MANAGE$ASSIGN_WF_ROLE"></asp:ImageButton>
                                    </td>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ImageButton2" runat="server" ToolTip="重置密码" ImageUrl="~/Images/ico_passwordset.gif" _KeyId='<%#Eval("USER_ID")%>'
                                            CausesValidation="False" OnClientClick="return resetPassword(this)" _visible="USER_MANAGE$RESET_PASSWORD">
                                        </asp:ImageButton>
                                    </td>
                                 
                                     <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="EnableImageButton" runat="server" ToolTip="启用"  _KeyId='<%#Eval("USER_ID")%>' _Status='<%#Eval("ACCOUNT_STATUS")%>'
                                            ImageUrl="~/Images/ico_start.gif" CausesValidation="False" OnClick="EnableUser" _visible="USER_MANAGE$ENABLE_USER">
                                        </asp:ImageButton>
                                 
                                        <asp:ImageButton ID="DisableImageButton" runat="server" ToolTip="停用"  _KeyId='<%#Eval("USER_ID")%>'
                                            ImageUrl="~/Images/ico_pause.gif" CausesValidation="False" OnClick="DisableUser"  _visible="USER_MANAGE$DISABLE_USER">
                                        </asp:ImageButton>
                                    </td>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnDelete" runat="server" ToolTip="删除" ImageUrl="~/Images/ico_del.gif" _KeyId='<%#Eval("USER_ID")%>'
                                            CausesValidation="False" OnClientClick="return window.confirm('您确认要删除该用户吗?')" OnClick="DeleteUser" _visible="USER_MANAGE$DELETE_USER">
                                        </asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                 <CheckBoxSettings Enabled="True" Position="0"/>
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="user.list"
             SelectCommandAutoPageWrap="true" DefaultSortExpression="USER_ID ASC">       
                        
            </web:SmartSqlDataSource>
        </div>
	</div>

      <script type="text/javascript">
          $(function () {
              $("#tbody_1").hide();
              $("#tbody_1").attr("type", "hide");
          });
            
          var orgId = '<%=Request.Params["OrgId"] %>';

          function openEditor(_this, action) {
              var url = "UserEdit.aspx";

              // FormViewMode : Insert/Edit/ReadOnly
              var params = { FormViewMode: action };

              if (action == "Insert") {
                  params.title = "用户信息新增";
                  params.OrgId = orgId;
              } else if (action == "Edit") {
                  params.title = "用户信息编辑";
                  params.UserId = _this.attributes["_KeyId"].value;
              }      

              var returnValue = showCenterModalDialog(buildUrl(url, params), 700, 240, null);
              return returnValue == "true";
          }

          function resetPassword(_this) {
              var url = "PasswordReset.aspx";
              var params = { UserId: _this.attributes["_KeyId"].value};
              var returnValue = showCenterModalDialog(buildUrl(url, params), 500, 210, null);
              return false;
          }

          function delFunctions() {
              var oSmartGridView1 = document.getElementById("<%=SmartGridView1.ClientID%>");
              var sValues = oSmartGridView1.control.getCheckedValues(true);

              if (sValues && sValues.length > 0) {
                  if (window.confirm("您确认要删除所选的用户吗？")) {
                      return true;
                  }
              }

              return false;
          }
          //分配管理角色
          function showUserRoleList(_this) {
              var url = "UserRole.aspx";

              var params = { UserId: _this.attributes["_KeyId"].value};
              var returnValue = showCenterModalDialog(buildUrl(url, params), 700,300, null);

              return false;
          }

          //分配流程角色
          function showUserWfRoleList(_this) {
              var url = "UserWfRole.aspx";

              var params = { UserId: _this.attributes["_KeyId"].value };
              var returnValue = showCenterModalDialog(buildUrl(url, params), 700, 300, null);

              return false;
          }

          function changeV(objID) {
              if ($("#tbody_" + objID).attr("type") == "show") {
                  $("#img_" + objID).attr("src", "../../../Images/ico_have2.gif");
                  $("#tbody_" + objID).attr("type", "hide");
                  $("#tbody_" + objID).hide();
              }
              else {
                  $("#img_" + objID).attr("src", "../../../Images/ico_nohave2.gif");
                  $("#tbody_" + objID).attr("type", "show");
                  $("#tbody_" + objID).show();
              }
          }
    </script>

</asp:Content>
